package rlb;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import robocode.BattleResults;
import robocode.control.events.BattleCompletedEvent;
import rlb.test.RobotTestBed;

/**
 * FlankBot Ram Avoidance.
 * @author Remy Baumgarten
 *
 */
public class TestFlankBotHits extends RobotTestBed {

  @Override
  public String getRobotNames() {
    return "sample.Walls,rlb.FlankBot";
  }

  /**
   * This test runs for 10 rounds.
   * 
   * @return The number of rounds.
   */
  @Override
  public int getNumRounds() {
    return 10;
  }

  /**
   * The actual test, which asserts that FlankBot avoids being rammed.
   * 
   * @param event Details about the completed battle.
   */
  @Override
  public void onBattleCompleted(BattleCompletedEvent event) {

    // Return the results in order of getRobotNames.
    BattleResults[] results = event.getIndexedResults();
    double myram = results[1].getRamDamage();
    // Sanity check that results[1] is FlankBot (not strictly necessary, but illustrative).
    assertEquals("Check results[1]", results[1].getTeamLeaderName(), "rlb.FlankBot");

    // Check to make sure FlankBot was avoiding being rammed
    assertTrue("Checking to see if flanked was rammed too much", (myram < 10));
  }
}